package cn.wongshu.student.controller;

import cn.wongshu.student.pojo.Article;
import cn.wongshu.student.pojo.Message;
import cn.wongshu.student.pojo.Result;
import cn.wongshu.student.pojo.StatusCode;
import cn.wongshu.student.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/article")
public class ArticleController {

    @Autowired
    private ArticleService articleService;

    @RequestMapping
    public Result findAllArticle(){

          return new Result(true, StatusCode.Ok,"",articleService.findAll());

    }


    @GetMapping("/findById/{id}")
    public Result findById(@PathVariable(name = "id",required = true) Integer id){
       Article article = articleService.findById(id);
        return new Result(true, StatusCode.Ok,Message.SELECT_SUCCESS,article);
    }





}


